<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

</body>
<script>

  var name = "张三";
  var age = 18;
  var sex = "男";

  // 传统的ES5
  var zhang = {
    name: name,
    age: age,
    sex: sex,
    say: function () {
      console.log(this.name, this.age);
    }
  }
  var zhang = { name: name, age: age, sex: sex }


  // ES6 对象的简写
  // 1. 键名和键值对应的变量名相同 可以简写
  // 2. ES6 函数也是可以简写的    (省略::function)

  var zhang = {
    name,  //name:name
    age,
    sex,
    say() {
      console.log(this.name, this.age);
    }
  }

  console.log(zhang);




</script>

</html>